/*     */ package com.feeyin.radar.sys.controller;
/*     */ 
/*     */ import com.feeyin.radar.sys.model.Operate;
/*     */ import com.feeyin.radar.sys.service.OperateService;
/*     */ import java.io.PrintStream;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.springframework.web.servlet.ModelAndView;
/*     */ import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
/*     */ import org.springframework.web.servlet.view.RedirectView;
/*     */ 
/*     */ public class OperateController extends MultiActionController
/*     */ {
/*     */   private OperateService operateService;
/*     */   private String addOperate;
/*     */   private String updateOperate;
/*     */ 
/*     */   public OperateService getOperateService()
/*     */   {
/*  30 */     return this.operateService;
/*     */   }
/*     */ 
/*     */   public void setOperateService(OperateService operateService) {
/*  34 */     this.operateService = operateService;
/*     */   }
/*     */ 
/*     */   public String getAddOperate() {
/*  38 */     return this.addOperate;
/*     */   }
/*     */ 
/*     */   public void setAddOperate(String addOperate) {
/*  42 */     this.addOperate = addOperate;
/*     */   }
/*     */ 
/*     */   public String getUpdateOperate() {
/*  46 */     return this.updateOperate;
/*     */   }
/*     */ 
/*     */   public void setUpdateOperate(String updateOperate) {
/*  50 */     this.updateOperate = updateOperate;
/*     */   }
/*     */ 
/*     */   public ModelAndView preAddOperate(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  55 */     request.setAttribute("result", request.getParameter("result"));
/*  56 */     request.setAttribute("repeat", request.getAttribute("repeat"));
/*  57 */     request.setAttribute("delete", request.getParameter("delete"));
/*     */ 
/*  59 */     String functionId = request.getParameter("functionId");
/*     */ 
/*  61 */     List operates = new ArrayList();
/*  62 */     if ((functionId != null) && (!"".equals(functionId))) {
/*  63 */       operates = this.operateService.getOperatesByFunctionId(Integer.valueOf(Integer.parseInt(functionId)));
/*     */     }
/*  65 */     request.setAttribute("functionId", functionId);
/*  66 */     request.setAttribute("operates", operates);
/*     */ 
/*  68 */     return new ModelAndView(getAddOperate());
/*     */   }
/*     */ 
/*     */   public ModelAndView addOperate(HttpServletRequest request, HttpServletResponse response, Operate operate)
/*     */   {
/*  73 */     boolean result = false;
/*  74 */     int success = 0;
/*  75 */     if ((operate != null) && (operate.getFunctionId() != null)) {
/*  76 */       if (this.operateService.getOperateByCode(operate.getOperateCode()) != null) {
/*  77 */         request.setAttribute("repeat", Integer.valueOf(1));
/*  78 */         request.setAttribute("operate", operate);
/*  79 */         return preAddOperate(request, response);
/*     */       }
/*     */ 
/*  82 */       result = this.operateService.insertOperate(operate);
/*  83 */       if (result) success = 1;
/*     */     }
/*  85 */     return new ModelAndView(
/*  86 */       new RedirectView("./operate.do?action=preAddOperate&functionId=" + operate.getFunctionId() + "&result=" + success));
/*     */   }
/*     */ 
/*     */   public ModelAndView preUpdateOperate(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  91 */     request.setAttribute("result", request.getParameter("result"));
/*  92 */     request.setAttribute("repeat", request.getAttribute("repeat"));
/*  93 */     request.setAttribute("delete", request.getParameter("delete"));
/*     */ 
/*  95 */     String functionId = request.getParameter("functionId");
/*     */ 
/*  97 */     List operates = new ArrayList();
/*  98 */     if ((functionId != null) && (!"".equals(functionId))) {
/*  99 */       operates = this.operateService.getOperatesByFunctionId(Integer.valueOf(Integer.parseInt(functionId)));
/*     */     }
/* 101 */     request.setAttribute("functionId", functionId);
/* 102 */     request.setAttribute("operates", operates);
/*     */ 
/* 104 */     return new ModelAndView(getUpdateOperate());
/*     */   }
/*     */ 
/*     */   public ModelAndView updateOperate(HttpServletRequest request, HttpServletResponse response, Operate operate)
/*     */   {
/* 109 */     boolean result = false;
/* 110 */     int success = 0;
/* 111 */     if ((operate != null) && (operate.getFunctionId() != null) && (operate.getId() != null)) {
/* 112 */       if (this.operateService.isRepeatUpdateOperate(operate)) {
/* 113 */         request.setAttribute("repeat", Integer.valueOf(1));
/* 114 */         request.setAttribute("operate", operate);
/* 115 */         return preUpdateOperate(request, response);
/*     */       }
/* 117 */       result = this.operateService.updateOperate(operate);
/* 118 */       if (result) success = 1;
/*     */     }
/* 120 */     return new ModelAndView(
/* 121 */       new RedirectView("./operate.do?action=preUpdateOperate&functionId=" + operate.getFunctionId() + "&result=" + success));
/*     */   }
/*     */ 
/*     */   public ModelAndView deleteOperateByAdd(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 126 */     boolean result = false;
/* 127 */     int success = 0;
/* 128 */     Integer functionId = Integer.valueOf(0);
/*     */ 
/* 130 */     String funcId = request.getParameter("functionId");
/* 131 */     if ((funcId != null) && (!"".equals(funcId))) {
/* 132 */       functionId = Integer.valueOf(Integer.parseInt(funcId));
/*     */     }
/*     */ 
/* 135 */     String id = request.getParameter("id");
/* 136 */     if ((id != null) && (!"".equals(id))) {
/* 137 */       result = this.operateService.deleteOperate(Integer.valueOf(Integer.parseInt(id)));
/*     */     }
/* 139 */     if (result) success = 1;
/* 140 */     System.out.println("success = " + success);
/*     */ 
/* 142 */     return new ModelAndView(new RedirectView("./operate.do?action=preAddOperate&functionId=" + functionId + "&delete=" + success));
/*     */   }
/*     */ 
/*     */   public ModelAndView deleteOperateByUpdate(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 147 */     boolean result = false;
/* 148 */     int success = 0;
/* 149 */     Integer functionId = Integer.valueOf(0);
/*     */ 
/* 151 */     String funcId = request.getParameter("functionId");
/* 152 */     if ((funcId != null) && (!"".equals(funcId))) {
/* 153 */       functionId = Integer.valueOf(Integer.parseInt(funcId));
/*     */     }
/*     */ 
/* 156 */     String id = request.getParameter("id");
/* 157 */     if ((id != null) && (!"".equals(id))) {
/* 158 */       result = this.operateService.deleteOperate(Integer.valueOf(Integer.parseInt(id)));
/*     */     }
/* 160 */     if (result) success = 1;
/*     */ 
/* 162 */     return new ModelAndView(new RedirectView("./operate.do?action=preUpdateOperate&functionId=" + functionId + "&delete=" + success));
/*     */   }
/*     */ }

/* Location:           C:\Users\e547415\MyProject\rone\WEB-INF\classes\
 * Qualified Name:     com.feeyin.radar.sys.controller.OperateController
 * JD-Core Version:    0.6.0
 */